package main

import (
	"encoding/json"
	"fmt"
	"os"
	"time"
)

type response1 struct {
	Page int
	Fruits []string
}

type response2 struct {
	Page int 		`json:"page"`
	Fruits []string `json:"fruits"`
}

func main()  {
	p := fmt.Println
	p(time.Now())
	bolB, _ := json.Marshal(true) 
	fmt.Println(string(bolB)) // true

	intB, _ := json.Marshal(1)
	fmt.Println(string(intB)) // 1

	fltB, _ := json.Marshal(2.34)
	fmt.Println(string(fltB)) // 2.34

	strB, _ := json.Marshal("gopher")
	fmt.Println(string(strB)) // "gopher"

	slcD := []string{"apple", "peach", "pear"} 
	slcB, _ := json.Marshal(slcD)
	fmt.Println(string(slcB)) // ["apple","peach","pear"]

	enc := json.NewEncoder(os.Stdout) // NewEncoder的参数需要传入一个os.writer，os.stdout就是标准输出
	d := map[string]int {"apple" : 5, "letture" : 10}
	enc.Encode(d)
}